package org.shindou09.easytagforpage.struts2.tags;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ComponentTagSupport;
import org.shindou09.easytagforpage.struts2.components.Page;

import com.opensymphony.xwork2.util.ValueStack;

public class PageTag extends ComponentTagSupport {

	private String name;

	private String url;

	private String theme;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTheme() {
		return theme;
	}

	public void setTheme(String theme) {
		this.theme = theme;
	}
	
	@Override
	protected void populateParams() {
		// TODO Auto-generated method stub
		super.populateParams();
		Page page=(Page) this.component;
		page.setName(name);
		page.setUrl(url);
		page.setTheme(theme);
		String pv="ftl";
		if(this.pageContext.getServletContext().getInitParameter("pageView")!=null){
			pv=this.pageContext.getServletContext().getInitParameter("pageView");
		}
		page.setTemplate(pv);
	}

	@Override
	public Component getBean(ValueStack arg0, HttpServletRequest arg1,
			HttpServletResponse arg2) {
		// TODO Auto-generated method stub
		return new Page(arg0);
	}

}
